import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class SMapPanel extends JPanel {
	public ImageIcon icon;

	public JLabel myLabel;
	public JPanel north;
	public JPanel center;
	public Color c1, c2, c3, c4, c5, c6;
	public ArrayList<SBarPanel> mapList;
	public ArrayList<String> mapNames;
	public Output o;
	
	public SMapPanel(Output arg1) {

		o = arg1;
		
		Color ctmp = Color.white.darker();

		c1 = new Color(105, 105, 105);
		c2 = ctmp;
		c3 = ctmp;
		c4 = new Color(75, 75, 75);
		c5 = new Color(77, 77, 77);

		this.setBackground(c1);
		this.setLayout(new BorderLayout());
		this.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createCompoundBorder(BorderFactory
						.createMatteBorder(2, 2, 0, 2, c2), BorderFactory
						.createMatteBorder(1, 1, 2, 2, c3)), BorderFactory
						.createMatteBorder(3, 3, 3, 3, c4)));

		north = new JPanel();
		north.setBackground(new Color(75, 75, 75));
		this.add(north, BorderLayout.NORTH);
		myLabel = new JLabel("Map Selection");
		myLabel.setFont(new Font("Dialog", Font.BOLD, 14));
		myLabel.setForeground(Color.white);
		north.add(myLabel);

		center = new JPanel();
		center.setBackground(new Color(105, 105, 105));
		center.setLayout(new GridLayout(7, 1));
		this.add(center, BorderLayout.CENTER);

		mapList = new ArrayList<SBarPanel>();
		mapNames = new ArrayList<String>();

		mapNames.add("Classic");
		mapNames.add("Europe");
		mapNames.add("Asia");
		mapNames.add("North America");

		for (int k = 0; k < 4; k++) {
			mapList.add(new SBarPanel(mapNames.get(k)));
			mapList.get(k).addMouseListener(new SMouseListener(mapList.get(k)));
			center.add(mapList.get(k));
		}
	}

	private class SMouseListener implements MouseListener {
		private SBarPanel myBarPanel;

		public SMouseListener(SBarPanel arg1) {
			myBarPanel = arg1;
		}

		public void mouseEntered(java.awt.event.MouseEvent evt) {
			if (!myBarPanel.clicked)
				myBarPanel.setBackground(new Color(35, 35, 35));
		}

		public void mouseExited(java.awt.event.MouseEvent evt) {
			if (!myBarPanel.clicked)
				myBarPanel.setBackground(new Color(60, 60, 60));
		}

		public void mouseClicked(java.awt.event.MouseEvent evt) {
			for (int k = 0; k < 4; k++) {
				mapList.get(k).setBackground(new Color(60, 60, 60));
				mapList.get(k).clicked = false;
			}
			myBarPanel.setBackground(new Color(35, 35, 35));
			o.customInfoPanel.setInfo(myBarPanel.myString);
			myBarPanel.clicked = true;
		}

		public void mousePressed(MouseEvent arg0) {
		}

		public void mouseReleased(MouseEvent arg0) {

		}
	}

}
